package com.clubs.coding.Controller;

import com.clubs.coding.Service.AppliCationService;
import com.clubs.coding.common.ApiRestResponse;
import com.clubs.coding.model.Vo.MakeItemNoVo;
import com.clubs.coding.model.pojo.Application;
import com.clubs.coding.model.request.DataReq;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


@Controller
@ResponseBody
@RequestMapping("/APPliCation")
public class AppliCationController {
@Autowired
AppliCationService appliCationService;
//报名
@PostMapping("/appli")

public ApiRestResponse appli(@RequestParam(value = "child" ,required = false,defaultValue = "1")Integer child, @RequestParam("name") String name,@RequestParam("mobile") String mobile,@RequestParam("maketimeId") Integer maketimeId,@RequestParam("openid")String openid) throws IOException {
appliCationService.appli(child,name, mobile, maketimeId,openid);

return ApiRestResponse.success();
}
//拿到已报名的用户名称
@GetMapping("/rename")
public ApiRestResponse rename(Integer makeTimeId){
    List rnames = appliCationService.rname(makeTimeId);


    return ApiRestResponse.success(rnames);


}
  // 获取我的所有报名
    @GetMapping("/isappli")
    public ApiRestResponse isappli(String openid, Integer pageNum,Integer pageSize){
        PageInfo pageInfo = appliCationService.isAppliAll(openid,pageNum, pageSize);

        return ApiRestResponse.success(pageInfo);


    }

/**
 * 我的今日预约
 * **/
@PostMapping("/myday")
public ApiRestResponse myDay(@RequestBody DataReq dataReq){
    List<MakeItemNoVo> makeItemNoVos = appliCationService.myDay(dataReq);
    return ApiRestResponse.success(makeItemNoVos);
}

}
